﻿/*!
* jQuery tree plugin: 
* 
* version 0.1 2011-03-10
* Requires jQuery v1.4.2 or later
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Authors: Kim Seoung Min
* Company : Kongyoung DB
*/

(function ($) {
    $.fn.superAutoSearch = function (method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.tooltip');
        }
    };

    //var AutocompleteisRun = false;

    var methods = {
        init: function (url, siteid) {
            var SuperAuto = $(this);
            var _SITEID = siteid;
            var pl = new JSONClientParameters();
            
            pl.add("QQ", _SITEID);
            
            PostJsonData(url, pl, function (data) {
                var _data = eval("data.Records");
                var Rows = _data.length;                
                $("#AutoCompleteUl").html("");
                if (Rows == 0) { return; }

                $(document.body).append("<div id='AutoCompleteDiv' class='ui-widget-content'><ul id='AutoCompleteUl' ></ul></div>");
                $("#AutoCompleteDiv").css("top", SuperAuto.offset().top + SuperAuto.outerHeight());
                $("#AutoCompleteDiv").css("left", SuperAuto.offset().left);

                for (var i = 0; i < Rows; i++) {
                    var DataRow = _data[i];
                    var datali = "<li class='AutoSerchItem' data='" + DataRow["CONTID"] + "'>" + DataRow["CSTNAME"] + "</li>";                    
                    $("#AutoCompleteUl").append(datali);
                }
            });
        },

        WhoIs: function () {
        }
    }
})(jQuery);


